package com.mstore.service;

import java.util.ArrayList;
import java.util.List;

import com.mstore.dao.BAnnouncementDao;
import com.mstore.pojo.BAnnouncement;

public class BAnnouncementService {

	private BAnnouncementDao bAnnouncementDao;

	/**
	 * 保存
	 */
	public void saveBAnnouncement(BAnnouncement bAnnouncement) {
		bAnnouncementDao.saveBAnnouncement(bAnnouncement);
	}

	/**
	 * 删除
	 */
	public void deleteBAnnouncement(BAnnouncement bAnnouncement) {
		bAnnouncementDao.deleteBAnnouncement(bAnnouncement);
	}

	/**
	 * 根据id查找单个
	 */
	public BAnnouncement selectById(BAnnouncement bAnnouncement) {
		BAnnouncement b = new BAnnouncement();
		b = (BAnnouncement) bAnnouncementDao.selectById(bAnnouncement);
		b.setCreateTime(b.getCreateTime().substring(0,
				b.getCreateTime().indexOf(".")));
		return b;
	}

	/**
	 * 查询所有积分公告
	 */
	public List<BAnnouncement> selectAll(BAnnouncement bAnnouncement) {
		List<BAnnouncement> list = new ArrayList<BAnnouncement>();
		List<Object> objects = bAnnouncementDao.selectAll(bAnnouncement);
		for (Object object : objects) {
			BAnnouncement b = (BAnnouncement) object;
			b.setCreateTime(b.getCreateTime().substring(0,
					b.getCreateTime().indexOf(".")));
			list.add(b);
		}
		return list;
	}

	/**
	 * 修改
	 */
	public void updateBAnnouncement(BAnnouncement bAnnouncement) {
		bAnnouncementDao.updatebAnnouncement(bAnnouncement);
	}

	public BAnnouncementDao getbAnnouncementDao() {
		return bAnnouncementDao;
	}

	public void setbAnnouncementDao(BAnnouncementDao bAnnouncementDao) {
		this.bAnnouncementDao = bAnnouncementDao;
	}

}
